//
//  AYTool.h
//  SuiXin
//
//  Created by mac on 2023/10/9.
//

#import <Foundation/Foundation.h>
#import "AY_ReadBookModel.h"

NS_ASSUME_NONNULL_BEGIN

@interface AYTool : NSObject

#pragma mark - 初始化
+ (AFHTTPSessionManager *)getManager;

+ (NSString *)getTimeNowDate;

#pragma mark - UI相关
+ (UIColor *)colorWithHexString:(NSString *)color;
+ (UIFont *)getFontWithSize:(CGFloat)size;
+ (CGFloat )getNumberWith:(CGFloat)num;
+ (UIButton *)createButtonWithFrame:(CGRect)frame andTitle:(NSString *__nullable)title andFont:(UIFont *__nullable)font andTitleColor:(UIColor *__nullable)titleColor andBg:(UIColor *__nullable)color andImage:(UIImage *__nullable)imgae andBgImage:(UIImage *__nullable)bgImage andTarget:(id __nullable)target andAction:(SEL __nullable)action andRadius:(CGFloat)radius andAddSubView:(UIView *__nullable)subView;
+ (UIView *)createViewWithFrame:(CGRect)frame andBg:(UIColor *__nullable)color andRadius:(CGFloat)radius andAddSubView:(UIView *__nullable)subView;
+ (UIImageView *)createImageViewWithFrame:(CGRect)frame andImage:(UIImage *__nullable)image andBg:(UIColor *__nullable)color andRadius:(CGFloat)radius andAddSubView:(UIView *__nullable)subView;
+ (UILabel *)createLabelWithFrame:(CGRect)frame andText:(NSString *__nullable)text andTextColor:(UIColor *__nullable)textColor andBgColor:(UIColor *__nullable)bgColor andFont:(UIFont *__nullable)font andLines:(int)lineCount andRadius:(CGFloat)radius andAddSubView:(UIView *__nullable)subView;

+ (UIWindow *)lastWindow;

+ (UIViewController *)viewControllerWith:(UIView *)childrenView;

+ (UITableView *)creatMyTableView:(CGRect)frame;
/**
 *  改变图片颜色
 */
+ (UIImage *)imageWithColor:(UIColor *)color and:(UIImage *)image;
/**
 设置渐变色
 @param color0 色值0
 @param color1 色值1
 @param size 尺寸
 @param type 方向 0水平方向 1竖直方向
 */
+ (UIColor *)customJianBianColorWithColor0:(UIColor *)color0 withColor1:(UIColor *)color1 withFrame:(CGSize)size withType:(NSInteger)type;

+ (NSString *)homeFileName:(NSString *)fileName;
// 获取电子书字体样式
+ (UIFont*)customFontWithPath:(NSString*)path size:(CGFloat)size;
// 电子书格式化
+ (NSString *)bookFormateWithContent:(NSString *)content;
// 正则匹配
+ (NSString *)bookMatchWithRegular:(NSString *)regular adnWithReplacementStr:(NSString *)str andWithContent:(NSString *)contentStr;
#pragma mark - 行间距
+ (NSMutableAttributedString *)LineSpacingTextWithText:(NSString *)text andSpace:(CGFloat)lineSpace;

#pragma mark - 获取文字
+ (NSString *)getContentWithUrl:(NSString *)url;

#pragma mark - 数据相关
+ (NSString *)md5String:(NSString *)string;
+ (NSString*)convertToJSONData:(id)infoDict;

+ (UIImage*)buttonImageFromColor:(UIColor*)color;

#pragma mark - 获取当前时间戳
+ (NSString *)getTimeNow;

#pragma mark - 获取手机型号
+ (NSString *)getPhoneDeviceType;

/**
 *  获取当前时间
 */
+(NSString *)getCurrentTime;

#pragma mark - ascii 排序
+ (NSString *)sortedDictionary:(NSDictionary *)dict;

#pragma mark - 获取UUID
+ (NSString *)getUUID;

#pragma mark - 网络header
+ (NSDictionary *)headerDic;

#pragma mark - 判断是否是夜间
+ (BOOL)isNight;

#pragma mark - 书籍状态
+ (void)setBookStatusWithStatus:(NSString *)status andLabel:(UILabel *)label;


#pragma mark - 排序算法

+ (NSArray *)sortASC:(NSArray *)ary;

#pragma 保存图书
+ (void)saveBooksWithBookId:(NSString *)bookId andPage:(NSInteger)page andChapterIndex:(NSInteger)chapterIndex;
+ (BOOL)isExistBookWithBookId:(NSString *)bookId andDataSource:(NSMutableArray *)dataSource;

#pragma 取出图书数据
+ (AY_ReadBookModel *)getBookDataWithBookId:(NSString *)bookId;

#pragma mark - DES加密
+ (NSString*)encrypt:(NSString*)plainText;
+ (NSString *)decryptUseDES:(NSString *)cipherText key:(NSString *)key;
// 切圆角
+ (void)cornerView:(UIView *)view andWithRoundingCorners:(UIRectCorner)corners ornerRadii:(CGSize)cornerRadii;
@end

NS_ASSUME_NONNULL_END
